/**
 * 
 */
package pt.mleiria.experiments;

import static java.lang.Integer.toBinaryString;

import java.util.BitSet;

import org.apache.log4j.Logger;

import pt.mleiria.bit.BitWiseUtils;
import pt.mleiria.bit.BytesConverter;

/**
 * @author NB13712
 *
 */
public class Main {
	private static final Logger LOG = Logger.getLogger(Main.class);
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		LOG.info(BytesConverter.fromHexadecimalToBinary(0x90 | 0x20));
		LOG.info(BytesConverter.fromHexadecimalToBinary("90"));
		LOG.info(BytesConverter.fromHexadecimalToBinary("20"));
		LOG.info(BytesConverter.fromHexadecimalToBinary("FF"));
		/*
		for(int mask = 1; mask < 0x100; mask = mask << 1){
			BitWiseUtils.fromHexadecimalToBinary(mask);
		}
		*/
		
	}
	public static void main1(String[] args) {
		try {

			for(int mask = 1; mask < 0x100; mask = mask << 1){
				//BitWiseUtils.fromHexadecimalToBinary(mask);
			}
			//BitWiseUtils.fromHexadecimalToBinary(0x100);
					
			//BitWiseUtils.fromHexadecimalToBinary("FF");
			byte allB = 0x0F;
			byte b = 0xff & 0x04;
			LOG.info(BytesConverter.fromHexadecimalToBinary(b));
			LOG.info(0xFF);
			LOG.info((byte)0xFF);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		//BitWiseUtils.fromHexadecimalToBinary("007f");
		//BitWiseUtils.fromHexadecimalToBinary("27");
				
	}
	
	public static void charArithmetic(){
		char myChar = 'A';
		System.out.println(myChar);
		//myChar++;
		System.out.println(toBinaryString(myChar));
		System.out.println(Integer.toHexString(myChar));
	}
	
	public static void wordToBinary(){
		String word = "Wiki";
		char[] wordChars = word.toCharArray();
		String result = "";
		for(int i = 0; i < wordChars.length; i++){
			result += toBinaryString(wordChars[i]) + " ";
		}
		System.out.println("Binary word->" + result);
	}
	public static void bitSet(){
		final BitSet bs = new BitSet();
		bs.set(0);
		bs.set(1);
		bs.set(1);
		bs.set(0);
		bs.set(0);
		bs.set(1);
		bs.set(1);
		bs.set(0);
		bs.set(1);
		bs.set(1);
		bs.set(0);
		bs.set(0);
		bs.set(1);
		bs.set(1);
		bs.set(0);
		bs.set(1);
		final BitSet mask = new BitSet();
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(1);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		mask.set(0);
		bs.and(mask);
		System.out.println(bs);

	}

}
